package com.qf.boot2202day03.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    MyInterceptor myInterceptor;

    @Autowired
    LoginInterceptor loginInterceptor;

    @Autowired
    AutoLoginInterceptor autoLoginInterceptor;
       /**
     * 添加自定义拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor)  // 拦截器对象
                .addPathPatterns("/hi/**")  // 要拦截的路径
                .excludePathPatterns("/hi/abc");  // 要放行的路径
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/plateform.html","/view/**");

       /* registry.addInterceptor(autoLoginInterceptor)
                .addPathPatterns("/login.html");*/
    }
}
